package com.example.mountainwalker.controller;


import com.example.mountainwalker.entity.ScenicSpotInfo;
import com.example.mountainwalker.mapper.ScenicSpotMapper;
import com.example.mountainwalker.service.ScenicSpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mw")
@CrossOrigin
public class ScenicSpotController {
    @Autowired
    private ScenicSpotService scenicSpotService;

    // http://localhost:8080/mw/ScenicSpotList
    @GetMapping("/ScenicSpotList")
    public List<ScenicSpotInfo> getScenicSpotList() {
        return scenicSpotService.getScenicSpotList();
    }

    // http://localhost:8080/mw/ScenicSpotById?id=1
    @GetMapping("/ScenicSpotById")
    public ScenicSpotInfo getScenicSpotById(Integer id) {
        return scenicSpotService.getScenicSpotById(id);
    }

    // http://localhost:8080/mw/deleteScenicSpotById?id=1
    @DeleteMapping("/deleteScenicSpotById")
    public int deleteScenicSpotById(Integer id) {
        return scenicSpotService.deleteScenicSpotById(id);
    }
    // http://localhost:8080/mw/addScenicSpot
    @PostMapping("/addScenicSpot")
    public int addScenicSpot(@RequestBody ScenicSpotInfo scenicSpotInfo) {
        return scenicSpotService.addScenicSpot(scenicSpotInfo);
    }

    // http://localhost:8080/mw/updateScenicSpot
    @PutMapping("/updateScenicSpot")
    public int updateScenicSpot(@RequestBody ScenicSpotInfo scenicSpotInfo) {
        return scenicSpotService.updateScenicSpot(scenicSpotInfo);
    }

}